﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using FirebirdSql.Data.FirebirdClient;
namespace University
{
    public partial class PROFCOMSTUD : University.PROFKOM
    {
       static string sqlSelect = "SELECT * FROM  PROFCOMSTUD";
        FbDataAdapter da = new FbDataAdapter(sqlSelect, con);
        DataTable dt = new DataTable();

       public PROFCOMSTUD(TreeNode node, ContextMenuStrip s, string com, int id)
            : base(node, s, com, id)
        {
            InitializeComponent();
            node_id = Convert.ToInt32(mynode.Tag.ToString());

            da.Fill(dt);
            bindingSource1.DataSource = dt;

            textBoxf.DataBindings.Add("Text", bindingSource1, "FACULTETU");
            bindingSource1.Filter = "UNIQUE_NO =" + node_id;
            if (com == "Remove") { Remove("PROFCOMSTUD"); Remove("VPROFCOMSTUD"); }
        }
       public override void Remove(string name)
       {
           base.Remove(name);
       }

       public override void UpdateForm()
       {
           OpenCon();
           UpdateFild("PROFCOMSTUD", "FACULTETU", textBoxf.Text);
           base.UpdateForm();

       }
       public override void InsertFild(string klas)
       {
           OpenCon();
           FbCommand cmdInsert = new FbCommand("INSERT INTO PROFCOMSTUD(UNIQUE_NO,FACULTETU) VALUES(@1,@2)", con);
           cmdInsert.Parameters.AddWithValue("1", textBox1.Text);
           cmdInsert.Parameters.AddWithValue("2", textBoxf.Text);
           cmdInsert.ExecuteNonQuery();

           FbCommand cmdInsert1 = new FbCommand("INSERT INTO VPROFCOMSTUD(UNIQUE_NO) VALUES(@1)", con);
           cmdInsert1.Parameters.AddWithValue("1", textBox1.Text);
           cmdInsert1.ExecuteNonQuery();
           base.InsertFild(klas);
       }
        public PROFCOMSTUD()
        {
            InitializeComponent();
        }
    }
}
